<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />

	<link rel="stylesheet" href="${request.getContextPath()}/static/bootstrap/bootstrap.min.css" />
	<link rel="stylesheet" href="${request.getContextPath()}/static/css/camera.css" />
	<link rel="stylesheet" href="${request.getContextPath()}/static/bootstrap/bootstrap-responsive.min.css" />
	<link rel="stylesheet" href="${request.getContextPath()}/static/bootstrap/matrix-login.css" />
	<link href="${request.getContextPath()}/static/bootstrap/font-awesome.css" rel="stylesheet" />

    <script type="text/javascript" src="${request.getContextPath()}/static/jquery/jquery-1.9.1.min.js"></script>
    <meta charset="UTF-8">
    <title>show all users</title>
</head>
<body>


	<div
		style="width:100%;text-align: center;margin: 0 auto;position: absolute;">
		<div id="loginbox">
		
			<form action="" method="post" name="loginForm"
						id="loginForm">
						<div class="control-group">
							<div class="controls">
								<div class="main_input_box">
									<span class="add-on bg_lg">
									<i><img height="37" src="${request.getContextPath()}/static/images/user.png" /></i>
									</span><input type="text" name="loginname" id="loginname" value="" placeholder="请输入用户名" />
								</div>
							</div>
						</div>
						<div class="control-group">
							<div class="controls">
								<div class="main_input_box">
									<span class="add-on bg_ly">
									<i><img height="37" src="${request.getContextPath()}/static/images/suo.png" /></i>
									</span><input type="password" name="password" id="password" placeholder="请输入密码" value="" />
								</div>
							</div>
						</div>
						<div class="form-actions">
							<div style="width:86%;padding-left:8%;">
		
								<span class="pull-right" style="padding-right:3%;"><a
									href="javascript:quxiao();" class="btn btn-success">重置</a></span> <span
									class="pull-right"><a onclick="severCheck();"
									class="flip-link btn btn-info" id="to-recover">登录</a></span>
		
							</div>
						</div>
		
			</form>
		</div>
	</div>

	<script src="${request.getContextPath()}/static/bootstrap/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="${request.getContextPath()}/static/jquery/jquery.tips.js"></script>
	<script type="text/javascript" src="${request.getContextPath()}/static/jquery/jquery.cookie.js"></script>
	
	<script type="text/javascript">
	
		//服务器校验
		function severCheck(){
			if(check()){
				
				var loginname = $("#loginname").val();
				var password = $("#password").val();
				//var code = "qq313596790fh"+loginname+",fh,"+password+"QQ978336446fh"+",fh,"+$("#code").val();
				$.ajax({
					type: "POST",
					url: '${request.getContextPath()}/login_check',
			    	data: {loginName:loginname,password:password,tm:new Date().getTime()},
					dataType:'json',
					cache: false,
					success: function(data){
						if("success" == data.result){
							//saveCookie();
							window.location.href="${request.getContextPath()}/index";
						}else if("userunknown" == data.result){
							login_tip.remove();
							$("#loginname").tips({
								side : 1,
								msg : "用户名不存在",
								bg : '#FF5080',
								time : 15
							});
							$("#loginname").focus();
						 }else if("usererror" == data.result){
							login_tip.remove();
							
							$("#loginname").tips({
								side : 1,
								msg : "密码有误",
								bg : '#FF5080',
								time : 15
							});
							$("#loginname").focus();
						}else if("disabled" == data.result){
							login_tip.remove();
							
							$("#loginname").tips({
								side : 1,
								msg : "账号被禁用",
								bg : '#FF5080',
								time : 15
							});
							$("#loginname").focus();
						}else{
							$("#loginname").tips({
								side : 1,
								msg : "缺少参数",
								bg : '#FF5080',
								time : 15
							});
							$("#loginname").focus();
						}
					}
				});
			}
		}
		
		//客户端校验
		function check() {

			if ($("#loginname").val() == "") {

				$("#loginname").tips({
					side : 2,
					msg : '用户名不得为空',
					bg : '#AE81FF',
					time : 3
				});

				$("#loginname").focus();
				return false;
			} else {
				$("#loginname").val(jQuery.trim($('#loginname').val()));
			}

			if ($("#password").val() == "") {

				$("#password").tips({
					side : 2,
					msg : '密码不得为空',
					bg : '#AE81FF',
					time : 3
				});

				$("#password").focus();
				return false;
			}

			login_tip = $("#loginbox").tips({
				side : 1,
				msg : '正在登录 , 请稍后 ...',
				bg : '#68B500',
				time : 10
			});

			return true;
		}
		
		function quxiao() {
			$("#loginname").val('');
			$("#password").val('');
		}
		
	</script>	
	
</body>
</html>  